# -*- coding: utf-8 -*-

def MergeSort(arr):
    if len(arr) <= 1:
        return arr
    mid = len(arr) // 2
    left = MergeSort(arr[:mid])
    right = MergeSort(arr[mid:])
    return Merge(left, right)

def Merge(left, right):
    r, l = 0, 0
    temp = []
    lmax = len(left)
    rmax = len(right)
    while l < lmax and r < rmax:
        if left[l] <= right[r]:
            temp.append(left[l])
            l += 1
        else:
            temp.append(right[r])
            r += 1
    temp += list(left[l:])
    temp += list(right[r:])
    return temp

s1 = [1,9,10,4,50,6,7,90,21,23,45]
print(MergeSort(s1))

            